# -*- coding: utf-8 -*-
__author__ = 'lztkdr'
__date__ = '2020/11/27 13:52'

from enum import Enum

Month = Enum('Monster', ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'))

# 类似于字典的键值对的形式
print(Month.Jan)  # 返回Monster.Jan

print('-------------------------------------')

"""
@unique装饰器可以帮助我们检查保证没有重复值。
"""

from enum import Enum, unique


@unique
class Weekday(Enum):
	Sun = 0  # Sun的value被设定为0
	Mon = 1
	Tue = 2
	Wed = 3
	Thu = 4
	Fri = 5
	Sat = 6


day = Weekday.Fri
print(day)
print(Weekday.Fri)
print(Weekday['Fri'])
print(Weekday.Fri.value)
print(Weekday(5))

print('-------------------------------------')

for member in Weekday:
	print(member, '--->', member.value)

print('-------------------------------------')
print(day is Enum)
print(day is Weekday)